{t assignTo=title}Add media{/t}
{include file="$MODULES_DIR/backoffice/templates/block/modal/ModalTitle.html" title=$title}

<script type="text/javascript">
{literal}

$(document).ready(function() {
{/literal}
    var path = '{$URL_RELATIVE}/?module%3Dmedias%26action%3DAjaxUpload%26docId%3D{$folder->getUniqueId()}%26docLang%3D{$folder->getLang()}%26backLang%3D{$backLang}';
{literal}
    $('#medias').uploadify({
{/literal}
    'uploader'  : '{$URL_RELATIVE}/js/lib/jQueryPlugins/jQueryUploadify.swf',
    'script'    : path,
    'checkScript': path+"%26checkScript%3Dtrue",
    'cancelImg' : '{$URL_RELATIVE}/themes/default/backend/medias/icons/1616/delete2', /*Need to be a png file*/
    'multi' : true,
    'buttonText' : ' ',
    'buttonImg': ' ',
    'width': 96,
    'height': 28,
    'sizeLimit' : {php}echo (int)ini_get('upload_max_filesize')*1000*1000;{/php}, /*1Mb*/
    'fileDesc' : 'Formats (jpg, jpeg, jpe, gif, png, tiff, tif, zip, rar, doc, pdf, xls, sit, ppt, csv, txt, rtf, docx, eps)',
    'fileExt' : '*.jpg;*.jpeg;*.jpe;*.gif;*.png;*.tiff;*.tif;*.zip;*.rar;*.doc;*.pdf;*.xls;*.sit;*.ppt;*.csv;*.txt;*.rtf;*.docx;*.eps',
    'wmode': 'transparent',
    {literal}
    'onSelectOnce': function(event, data)
                    {
                        $('#totalFiles').text(data.fileCount);
                        $('#totalKbs').text(Math.round(data.allBytesTotal/1024));
                    },
    'onCheck': function(event, checkScript, fileQueue, ID)
               {
                    var replaceFile = confirm(getLocale('medias.locales.replaceMedia', {file:fileQueue[ID]}));
                    if (!replaceFile)
                    {
                        $("#" + $(event.target).attr('id')).uploadifyCancel(ID);
                    }
                    return false;
               },
    'onComplete': function(event, ID, fileObj, response, data)
                {
                    $("#"+ $(event.target).attr('id') + ID + " .percentage").text(' - ' + unescape(response));
                    return false;
                }
    });
});

function refreshList()
{
    $.nyroModalSettings({
        endRemove: function()
        {
{/literal}
        {if $mce}
                loadFolderContent();
        {else}
                $.historyLoad(document.location.toString().replace(/^.*#/, ''), true, false);
        {/if}
{literal}
        }
    });
}

{/literal}
</script>




<div style="height:340px;" id="modalContent">
    <div id="up_header">
        <div id="up_upload_btn">
            <span>{t}BROWSE{/t}</span>
            <div id="medias" />
        </div>
        <div id="up_emptylist">
            <a href="javascript:void(0)" onclick="$('#medias').uploadifyClearQueue();">{t}EMPTY LIST{/t}</a>
        </div>
    </div>
</div>
</div></td><td id="modalRightShadow">&nbsp;</td></tr></table>
<div id="modalFooter">
    <table width="100%">
        <tr>
            <td id="modalBarLeft"><div></div></td>
            <td id="modalBarMid">
                <div>
                    <span class="up_cancel">&nbsp;</span>
                    <span class="up_fileName" style="text-align: left; height: 30px; line-height: 30px;"><span id="totalFiles">0</span> {t}files{/t} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="totalKbs">0</span> {t}Kb{/t}</span>
                    <button type="button" class="nyroModalClose bigGreyButton" >{t}Close{/t}</button>
                    <button type="button" class="bigGreenButton" onclick="$('#medias').uploadifyUpload(); refreshList();">{t}Import{/t}</button>
                </div>
            </td>
            <td id="modalBarRight"><div></div></td>
        </tr>
    </table>
</div>